package com.consumer.config;

import com.consumer.entity.User;
import org.springframework.stereotype.Component;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @Description    jvm缓存类
 * @Author youxin
 * @Version V1.0.0
 * @Since 1.0
 * @Date 2021/11/17
 */
@Component
public class LoginCachManaher {

    /**
     * 登录信息缓存
     */
    private ConcurrentHashMap<String, User> loginCachMap = new ConcurrentHashMap<>();

    /**
     * 根据登录记录id 获取登录信息
     */
    public User getLoginLog(String id) {
        User user = loginCachMap.get(id);
        return user;
    }

    /**
     * jvm 缓存录入
     */
    public void saveLoginCach(User user){
        loginCachMap.put(user.getId(),user);
    }


}
